package cn.zkld.Data;

import lombok.Data;

import java.io.Serializable;

/**
 * Created by 李景辉 on 2017/12/10.
 */
@Data
public class FrontResult<T>  implements Serializable {
    public static final int SUCCESS_CODE = 0;
    private static final String SUCCESS_MESSAGE = "请求成功！";
    public static final int FAIL_CODE = 1;
    private static final String FAIL_MESSAGE = "请求失败！";
    /**
     * 提示码
     **/
    private int code;

    /**
     * 提示信息
     **/
    private String message;

    /**
     * 返回数据
     **/
    private T data;

    public static <T> FrontResult<T> wrapSuccessfulResult(T data) {
        FrontResult<T> result = new FrontResult();
        result.code = SUCCESS_CODE;
        result.message = SUCCESS_MESSAGE;
        result.data = data;
        return result;
    }

    public static <T> FrontResult<T> wrapFailureResult() {
        FrontResult<T> result = new FrontResult();
        result.code = FAIL_CODE;
        result.message = FAIL_MESSAGE;
        return result;
    }

}
